/**
 * pharma-business - 27 févr. 2011
 * guillaume
 */
package org.bspv.pharma.business.rules;

import java.util.List;

import org.apache.commons.collections.CollectionUtils;

/**
 * @author guillaume
 *
 */
public abstract class AbstractCompositeSpecification<T> implements Specification<T> {

    /**
     * Liste de spécifications.
     */
    protected List<Specification<T>> specifications;

    /**
     * Constructeur par défaut.
     * @param specifications
     */
    public AbstractCompositeSpecification(Specification<T>... specifications) {
        super();
        CollectionUtils.addAll(this.specifications, specifications);
    }
    
    /**
     * 
     */
    @SuppressWarnings("unchecked")
    public Specification<T> or(Specification<T> specification) {
        return new OrSpecification<T>(this, specification);
    }

    /**
     * 
     */
    @SuppressWarnings("unchecked")
    public Specification<T> and(Specification<T> specification) {
        return new AndSpecification<T>(this, specification);
    }
    
    /**
     * 
     */
    @SuppressWarnings("unchecked")
    public Specification<T> not() {
        return new NotSpecification<T>(this);
    }
    
}
